﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using YXShop.Common;

namespace YXShop.Web.admin.store
{
    public partial class storemessage_view : System.Web.UI.Page
    {
        YXShop.BLL.Store.StoreMessage storeMsgBll = new YXShop.BLL.Store.StoreMessage();
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                int id = ChangeHope.WebPage.PageRequest.GetQueryInt("id");
                if (id > 0)
                {
                    YXShop.Common.PromptInfo.Popedom("014003001", "对不起，您没有权限进行修改");
                }
                else
                {
                    ChangeHope.WebPage.Script.GoBack();
                }
                if (id > 0)
                {
                    GetMessage(id);
                }
            }
        }

        private void GetMessage(int id)
        {
            YXShop.Common.SysParameter sp = new YXShop.Common.SysParameter();
            YXShop.Model.Store.StoreMessage s = new Model.Store.StoreMessage();
            YXShop.BLL.Admin.Administrators adminBLL = new BLL.Admin.Administrators();
            YXShop.Model.Admin.AdminInfo admin = YXShop.Common.AdministrorManager.Get();
            YXShop.BLL.Store.StoreCenter scBLL = new BLL.Store.StoreCenter();
            s = storeMsgBll.GetModelById(id);
            lblTitle.Text = s.MessageTitle;
            litMessage.Text = s.Message;
            if (s.Storecenterid.Value != 0)
            {
                trStroeCenter.Visible = true;
                YXShop.Model.Store.StoreCenter sc = scBLL.GetModelById(s.Storecenterid.Value);
                lblStoreCenter.Text = sc.StoreCentername;
            }
            lblCategory.Text = ValuePair.GetMessageCategory(s.MessageCategory.Value);
            hlAccessory1.NavigateUrl = sp.DummyPaht+ s.Accessory1;
            hlAccessory1.Text = s.Accessory1.Substring(s.Accessory1.LastIndexOf("/") + 1);
            hlAccessory2.NavigateUrl =sp.DummyPaht+ s.Accessory2;
            hlAccessory2.Text = s.Accessory2.Substring(s.Accessory2.LastIndexOf("/") + 1);
            hlAccessory3.NavigateUrl = sp.DummyPaht + s.Accessory3;
            hlAccessory3.Text = s.Accessory3.Substring(s.Accessory3.LastIndexOf("/") + 1);
            hlAccessory4.NavigateUrl = sp.DummyPaht + s.Accessory4;
            hlAccessory4.Text = s.Accessory4.Substring(s.Accessory4.LastIndexOf("/") + 1);
            hlAccessory5.NavigateUrl = sp.DummyPaht + s.Accessory5;
            hlAccessory5.Text = s.Accessory5.Substring(s.Accessory5.LastIndexOf("/") + 1);
            lblSenderTime.Text = s.SenderTime.Value.ToString();
            lblSenderID.Text = adminBLL.GetModel(s.SenderId.Value).Name;
            
        }
    }
}
